package cn.org.eshow.model;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 平台财务表
 */
@Entity
@Table(name = "finance")
@Cache(usage = CacheConcurrencyStrategy.NONE)
public class Finance extends BaseObject implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;//店铺财务表ID

    @Column(name = "add_time", nullable = false, length = 0)
    private Date addTime;//添加时间

    @Column(name = "update_time", nullable = false, length = 0)
    private Date updateTime;//更新时间

    @Column
    private Double balance;//可用金额

    @Column
    private Double frozen;//冻结金额

    @Column(name = "online_refund")
    private Double onlineRefund;//线上退款金额

    @Column(name = "offline_refund")
    private Double offlineRefund;//线上退款金额

    @Column
    private Double turnover;//总营业额

    @Column(name = "year_turnover")
    private Double yearTurnover;//本年营业额

    @Column(name = "month_turnover")
    private Double monthTurnover;//本月营业额

    @Column(name = "today_turnover")
    private Double todayTurnover;//今日营业额


    @Column
    private Boolean enabled = Boolean.TRUE;//是否可用


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Double getBalance() {
        return balance;
    }

    public void setBalance(Double balance) {
        this.balance = balance;
    }

    public Double getFrozen() {
        return frozen;
    }

    public void setFrozen(Double frozen) {
        this.frozen = frozen;
    }

    public Date getAddTime() {
        return addTime;
    }

    public void setAddTime(Date addTime) {
        this.addTime = addTime;
    }

    public Double getOnlineRefund() {
        return onlineRefund;
    }

    public void setOnlineRefund(Double onlineRefund) {
        this.onlineRefund = onlineRefund;
    }

    public Double getOfflineRefund() {
        return offlineRefund;
    }

    public void setOfflineRefund(Double offlineRefund) {
        this.offlineRefund = offlineRefund;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public Double getTurnover() {
        return turnover;
    }

    public void setTurnover(Double turnover) {
        this.turnover = turnover;
    }

    public Double getYearTurnover() {
        return yearTurnover;
    }

    public void setYearTurnover(Double yearTurnover) {
        this.yearTurnover = yearTurnover;
    }

    public Double getMonthTurnover() {
        return monthTurnover;
    }

    public void setMonthTurnover(Double monthTurnover) {
        this.monthTurnover = monthTurnover;
    }


    public Double getTodayTurnover() {
        return todayTurnover;
    }

    public void setTodayTurnover(Double todayTurnover) {
        this.todayTurnover = todayTurnover;
    }

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", this.id)
                .append("addTime", this.addTime)
                .append("updateTime", this.updateTime)
                .append("balance", this.balance)
                .append("frozen", this.frozen)
                .append("onlineRefund", this.onlineRefund)
                .append("offlineRefund", this.offlineRefund)
                .append("enabled", this.enabled)
                .toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || this.getClass() != o.getClass())
            return false;
        Finance pojo = (Finance) o;
        if (id != null ? !pojo.id.equals(id) : pojo.id != null)
            return false;
        if (balance != null ? !pojo.balance.equals(balance) : pojo.balance != null)
            return false;
        if (updateTime != null ? !pojo.updateTime.equals(updateTime) : pojo.updateTime != null)
            return false;
        if (frozen != null ? !pojo.frozen.equals(frozen) : pojo.frozen != null)
            return false;
        if (offlineRefund != null ? !pojo.offlineRefund.equals(offlineRefund) : pojo.offlineRefund != null)
            return false;
        if (onlineRefund != null ? !pojo.onlineRefund.equals(onlineRefund) : pojo.onlineRefund != null)
            return false;
        if (enabled != null ? !pojo.enabled.equals(enabled) : pojo.enabled != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = 0;
        result = result * 31 + (id != null ? id.hashCode() : 0);
        result = result * 31 + (balance != null ? balance.hashCode() : 0);
        result = result * 31 + (updateTime != null ? updateTime.hashCode() : 0);
        result = result * 31 + (frozen != null ? frozen.hashCode() : 0);
        result = result * 31 + (onlineRefund != null ? onlineRefund.hashCode() : 0);
        result = result * 31 + (offlineRefund != null ? offlineRefund.hashCode() : 0);
        result = result * 31 + (enabled != null ? enabled.hashCode() : 0);
        return result;
    }


}
